package com.example.orderservice.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.orderservice.entity.PageVO;
import com.example.orderservice.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lenovo
 * @Description
 * @Date2025/4/18 下午2:38
 * 调用商品服务的rest客户端
 */

@FeignClient(value = "product-service")
public interface ProductServiceFeignClient {

    @RequestMapping("/product/{id}")
    ResponseEntity<Product> findProductById(@PathVariable Integer id);

    @GetMapping("/products")
    ResponseEntity<List<Product>> findAllProducts();


    @GetMapping("product-page")
    ResponseEntity<PageVO> findProductsPage(@RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                                            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pagesize);

    @PostMapping("/product")
    ResponseEntity<String> addProduct(@RequestBody Product product);

    @PutMapping("/product")
    ResponseEntity<String> updateProduct(@RequestBody Product product);

    @DeleteMapping("/product/{id}")
    ResponseEntity<String> deleteProduct(@PathVariable Integer id);
}
